import React from 'react';
import { Button, Text, View } from 'react-native';
import { RootStackNavigation } from '../navigator/index';

interface IProps {
  navigation: RootStackNavigation;
}

class Account extends React.Component<IProps> {
  onPress = () => {
    //从this.props中得到navigation
    const { navigation } = this.props;
    //navigation中有一个叫navigate的函数来进行堆栈导航器的页面跳转（通过关键字'Detail'来实现跳转）
    navigation.navigate('Detail', {
      id: 2,//跳转时携带的参数
    });
  };

  render() {
    return (
      <View>
        <Text>Account</Text>
        <Button title="跳转到详情页" onPress={this.onPress} />
      </View>
    );
  }
}

export default Account;
